﻿@model ProductDetailsModel
@using IT.CMS.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
}
@{
    //errors
    var errors = new List<string>();
    foreach (var modelState in ViewData.ModelState.Values)
    {
        foreach (var error in modelState.Errors)
        {
            errors.Add(error.ErrorMessage);
        }
    }
}
<div class="page product-details-page">
    <div class="page-body">
        @Html.Widget("mobile_productdetails_top")
        @*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@
        @using (Html.BeginRouteForm("Product", new RouteValueDictionary() { { "SeName", Model.SeName } }, FormMethod.Post, new Dictionary<string, Object> { { "data-ajax", "false" }, { "enctype", "multipart/form-data" } }))
        {
            <div class="product-essential">
                <div class="overview">
                    <h1 class="product-name">
                        @Model.Name
                    </h1>
                    @if (errors.Count > 0)
                    { 
                        <div class="message-error">
                            <ul>
                                @for (int i = 0; i < errors.Count; i++)
                                {
                                    <li>@errors[i]</li>
                                }
                            </ul>
                        </div>
                    }
                    @if (!String.IsNullOrEmpty(Model.ShortDescription))
                    {
                        <div class="short-description">
                            @Html.Raw(Model.ShortDescription)
                        </div>
                    }
                    @Html.Widget("mobile_productdetails_before_pictures")
                    @Html.Partial("_ProductDetailsPictures", Model)
                    @Html.Widget("mobile_productdetails_after_pictures")
                    @Html.Action("ProductManufacturers", "Catalog", new { productId = Model.Id })
                    @Html.Action("ProductReviewOverview", "Catalog", new { productId = Model.Id })
                    @Html.Action("ProductEmailAFriendButton", "Catalog", new { productId = Model.Id })
                    @Html.Action("CompareProductsButton", "Catalog", new { productId = Model.Id })
                </div>
                @if (!String.IsNullOrEmpty(Model.FullDescription))
                {
                    <div class="full-description">
                        @Html.Raw(Model.FullDescription)
                    </div>
                }
            </div>
            <div class="product-collateral">
                <div class="product-variant-list">
                    @foreach (var variant in Model.ProductVariantModels)
                    {
                        var dataDictVariant = new ViewDataDictionary();
                        dataDictVariant.TemplateInfo.HtmlFieldPrefix = string.Format("variant_{0}", variant.Id);
                        @Html.Partial("_ProductVariantLine", variant, dataDictVariant)
                    }
                </div>
                @Html.Action("ProductSpecifications", "Catalog", new { productId = Model.Id })
                <div class="clear">
                </div>
                @Html.Action("ProductTags", "Catalog", new { productId = Model.Id })
                <div class="clear">
                </div>
                @Html.Action("ProductsAlsoPurchased", "Catalog", new { productId = Model.Id })
                @Html.Action("RelatedProducts", "Catalog", new { productId = Model.Id })
            </div>
        }
        @Html.Widget("mobile_productdetails_bottom")
    </div>
</div>
